package com.zy.fee.roadpark.activity.np;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.support.v7.widget.GridLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.Gravity;
import android.view.View;
import android.view.WindowManager;
import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import com.zy.fee.roadpark.R;
import com.zy.fee.roadpark.model.M_NpNodeRecord;
import com.zygk.library.util.ImageUtil;
import com.zygk.library.util.imagePicker.ImageAdapter;
import java.util.Arrays;

public class LeaveNotPicDetailActivity extends Activity {
  @BindView(R.id.recyclerView) RecyclerView recyclerView;

  Context mContext;
  Activity mActivity;
  private ImageAdapter imageAdapter;
  M_NpNodeRecord npNodeRecord;

  @Override protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setFinishOnTouchOutside(true);
    setContentView(R.layout.activity_leave_not_pic_detail);
    ButterKnife.bind(this);
    getWindow().setGravity(Gravity.CENTER);
    //设置布局填充满宽度
    WindowManager.LayoutParams layoutParams = getWindow().getAttributes();
    layoutParams.width = WindowManager.LayoutParams.MATCH_PARENT;
    layoutParams.height = WindowManager.LayoutParams.MATCH_PARENT;
    getWindow().setAttributes(layoutParams);

    init();
  }

  private void init() {
    initData();
    initView();
  }

  private void initData() {
    mContext = this;
    mActivity = this;
    npNodeRecord = (M_NpNodeRecord) getIntent().getSerializableExtra("NodeRecord");
  }

  private void initView() {
    recyclerView.setLayoutManager(new GridLayoutManager(this, 3));
    recyclerView.setHasFixedSize(true);
    imageAdapter = new ImageAdapter(mContext, Arrays.asList(npNodeRecord.getHandlePics().split(",")));
    recyclerView.setAdapter(imageAdapter);

    imageAdapter.setOnItemClickLitener(
        pos -> ImageUtil.browserPics(npNodeRecord.getHandlePics(), mContext, pos));
  }

  @OnClick({
      R.id.tv_yes
  }) public void onViewClicked(View view) {
    Intent intent;
    switch (view.getId()) {
      case R.id.tv_yes:
        finish();
        break;
    }
  }
}
